import pickle
import random
from Config.Config import ACTNET200V13_PKL

with open(ACTNET200V13_PKL,'rb') as f:
    data = pickle.load(f)

dataset = data['database']
vids = list(dataset.keys())

labels_count_train = dict()
labels_count_val = dict()

for vid in vids:
    item = dataset[vid]
    if item['subset'] == 'validation':
        label = item['annotations'][0]['label']
        labels_count_val[label] = labels_count_val.get(label,0)+1
        if labels_count_val[label] > 80:
            item['subset'] = 'training'
        else:
            if random.choice([True,False,True,True]):
                item['subset'] = 'training'

vids = list(dataset.keys())
a=0
b=0
c=0
for vid in vids:
    item = dataset[vid]
    if item['subset'] == 'validation':
        a+=1
    elif item['subset'] == 'training':
        b+=1
    else:
        c+=1

print(a,b,c)

with open('/tmp/moretrain_actNet200-V1-3.pkl','wb') as f:
    pickle.dump(dataset,f)
